package com.health.yb.core.utils;

/**
 *
 * @Description 数字转中文工具类
 * @author rjwang
 * @version 1.0
 * @date 2019/12/10 16:32
 */
public class NumFormatUtil {

    /**
     * 纯数字转中文汉字
     * blog.csdn.net/MrJavaweb/article/details/78136733
     * @param str
     * @return
     */
    private static String toChinese(String str) {
        String[] s1 = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
        String[] s2 = { "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千" };
        String result = "";
        int n = str.length();
        for (int i = 0; i < n; i++) {
            int num = str.charAt(i) - '0';
            if (i != n - 1 && num != 0) {
                result += s1[num] + s2[n - 2 - i];
            } else {
                result += s1[num];
            }
        }
        return result;
    }
}
